/*
    Project:        Home Power Control
    File:           HPCButton.h
    Author:         christian@karunamusic.at
    Date:           12.2014
    Description:    Simple class to cover a button.
 */

#ifndef HPCBUTTON_H
#define HPCBUTTON_H

#include <string>
#include <HPCThreadedSensor.h>


/** \brief Simple threaded sensorclass to cover a button.
 */
class HPCButton : public HPCThreadedSensor
{
public:
    /** \brief Constructor
     *
     * \param id database id of the sensor.
     * \param pin GPIO pin number.
     * \param interval time (in seconds) to pause between querying the sensor.
     */
    HPCButton( unsigned long id, unsigned int pin, unsigned int interval );
    /** \brief Destructor.
     */
    virtual ~HPCButton();

    /** \brief Get the type of the sensor.
     *
     * \return SensorType Type of the sensor (from enum SensorType).
     */
    virtual inline SensorType Type() const
      { return SensorType::HPCButton; }

protected:
    /** \brief Get a value from the sensor.
     */
    virtual void Measure();

    /** \brief Check if sensor has changed (called after interval pause).
     *
     * \return True if changed.
     */
    virtual bool hasChanged();
};

#endif // HPCBUTTON_H
